package com.applcn.message.controller.feign;

import com.applcn.core.base.Result;
import com.applcn.message.dto.SendSmsCodeDTO;
import com.applcn.message.utils.sms.SmsUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * com.applcn.message.controller
 * Description:
 *
 * @author: 大妖怪
 * @date: 2020-02-06 14:42
 */
@RestController
@RequestMapping("/feign/message")
@RequiredArgsConstructor
public class SmsFeign {

    private final SmsUtil smsUtil;

    /**
     * 发送短信验证码
     *
     * @return
     */
    @PostMapping("/sendSmsCode")
    public Result sendMessage(@RequestBody @Validated SendSmsCodeDTO sendSmsCodeDTO) {
        return smsUtil.sendMessage(sendSmsCodeDTO.getPhone(), sendSmsCodeDTO.getSmsSign(), sendSmsCodeDTO.getTemplateId(),
                sendSmsCodeDTO.getCode(), sendSmsCodeDTO.getExpire());
    }
}
